<?php


namespace app\index\controller;


use app\index\model\Info;
use think\facade\View;
use \app\index\model\Article;

class Index extends IndexController {
    public function index() {

        try {
            $articleObj = new Article();
            $data = [
                'zhongDianTuiJian' => $articleObj->getArticleTitleByCategory($this->category['zhongDianTuiJian']['category_id'], $this->category['zhongDianTuiJian']['category_name'], 10),
                'caiGouGongGao' => $articleObj->getArticleTitleByCategory($this->category['caiGouGongGao']['category_id'], $this->category['caiGouGongGao']['category_name']),
                'changSuoFuWu' => $articleObj->getArticleTitleByCategory($this->category['changSuoFuWu']['category_id'], $this->category['changSuoFuWu']['category_name']),
                'kuangChanPinJiaoYI' => $articleObj->getArticleTitleByCategory($this->category['kuangChanPinJiaoYI']['category_id'], $this->category['kuangChanPinJiaoYI']['category_name']),
                'qiTaGongGao' => $articleObj->getArticleTitleByCategory($this->category['qiTaGongGao']['category_id'], $this->category['qiTaGongGao']['category_name']),
            ];
//            return show(config('status.success'), 'test', $data['caiGouGongGao']);

        } catch (\Exception $e) {
            return show(config('status.success'), $e->getMessage());
        }
//        return show(config('status.success'), 'test', $this->header);

        return View::fetch('', [
            'category' => $this->category,
            'category_name' => $this->categoryName,
            'bar' => $this->header,
            'banner' => $this->banner,
            'res' => $data,
            'info' => $this->info,
        ]);
    }
}